gdk/gdkvulkancontext.c: Avoid VLAs
authorChun-wei Fan <fanchunwei@src.gnome.org>
Wed, 28 Dec 2016 14:34:04 +0000 (22:34 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Thu, 29 Dec 2016 09:51:56 +0000 (17:51 +0800)
During the drive to enable Vulkan context creation on Windows, some more
VLAs were found here.  Replace them with g_newa().

https://bugzilla.gnome.org/show_bug.cgi?id=773299

gdk/gdkvulkancontext.c

index d5622913e186b0adf486db4af574f99aa006f159..e64cd2f1eb44b002bb0dd7fe5ab69d77e9b1b2d0 100644 (file)
@@ -431,7 +431,7 @@ gdk_vulkan_context_real_init (GInitable     *initable,
       GDK_VK_CHECK (vkGetPhysicalDeviceSurfaceFormatsKHR, gdk_vulkan_context_get_physical_device (context),
                                                           priv->surface,
                                                           &n_formats, NULL);
-      VkSurfaceFormatKHR formats[n_formats];
+      VkSurfaceFormatKHR *formats = g_newa (VkSurfaceFormatKHR, n_formats);
       GDK_VK_CHECK (vkGetPhysicalDeviceSurfaceFormatsKHR, gdk_vulkan_context_get_physical_device (context),
                                                           priv->surface,
                                                           &n_formats, formats);
@@ -577,7 +577,7 @@ gdk_display_create_vulkan_device (GdkDisplay  *display,
 
   uint32_t n_devices;
   GDK_VK_CHECK(vkEnumeratePhysicalDevices, display->vk_instance, &n_devices, NULL);
-  VkPhysicalDevice devices[n_devices];
+  VkPhysicalDevice *devices = g_newa (VkPhysicalDevice, n_devices);
   GDK_VK_CHECK(vkEnumeratePhysicalDevices, display->vk_instance, &n_devices, devices);
 
   if (n_devices == 0)
@@ -609,7 +609,7 @@ gdk_display_create_vulkan_device (GdkDisplay  *display,
 
       uint32_t n_queue_props;
       vkGetPhysicalDeviceQueueFamilyProperties (devices[i], &n_queue_props, NULL);
-      VkQueueFamilyProperties queue_props[n_queue_props];
+      VkQueueFamilyProperties *queue_props = g_newa (VkQueueFamilyProperties, n_queue_props);
       vkGetPhysicalDeviceQueueFamilyProperties (devices[i], &n_queue_props, queue_props);
 
       for (j = 0; j < n_queue_props; j++)
@@ -707,7 +707,7 @@ gdk_display_create_vulkan_instance (GdkDisplay  *display,
 
   uint32_t n_extensions;
   GDK_VK_CHECK (vkEnumerateInstanceExtensionProperties, NULL, &n_extensions, NULL);
-  VkExtensionProperties extensions[n_extensions];
+  VkExtensionProperties *extensions = g_newa (VkExtensionProperties, n_extensions);
   GDK_VK_CHECK (vkEnumerateInstanceExtensionProperties, NULL, &n_extensions, extensions);
 
   used_extensions = g_ptr_array_new ();
@@ -731,7 +731,7 @@ gdk_display_create_vulkan_instance (GdkDisplay  *display,
 
   uint32_t n_layers;
   GDK_VK_CHECK (vkEnumerateInstanceLayerProperties, &n_layers, NULL);
-  VkLayerProperties layers[n_layers];
+  VkLayerProperties *layers = g_newa (VkLayerProperties, n_layers);
   GDK_VK_CHECK (vkEnumerateInstanceLayerProperties, &n_layers, layers);
 
   used_layers = g_ptr_array_new ();